1. Field of the Invention
The present invention relates to a data stream generation apparatus for generating a data stream of a predetermined data length from an input data stream and a method of the same. The present invention also relates to a variable length data stream generation apparatus for applying such an apparatus and method to variable length encoding, for example, JPEG, to generate a predetermined data stream and a method of the same. The present invention further relates to a camera system for variably encoding and processing a signal of a picked up image.
2. Description of the Related Art
There are various schemes for encoding image data, audio data, etc. The JPEG (Joint Photographic Experts Group) scheme is a typical example which is widely used when encoding still images.
In the JPEG, various control codes referred to as markers are used in order to define the structure of a compressed and encoded bit stream.
For example, in the encoding scheme using a discrete cosine transform (DCT) employed in the JPEG, the amount of information is reduced by encoding DC components of DCT coefficients having a high correlation among blocks by a differential value between adjoining blocks. For this reason, when an error occurs in the data due to some cause or another when transferring the JPEG compressed and encoded data, there is a great effect upon the later following blocks. In order to prevent this, in JPEG image data, a marker referred to as a “restart marker” (RSTm) for clearing the held DC component values is inserted into the bit stream for every set of blocks of for example 8×8 pixels, that is, every unit referred to as a minimum coded unit (MCU).
There are also markers such as the start-of-image (SOI) marker indicating the start of one image and the end-of-image (EOI) marker indicating the end of the image. These markers are allocated 2-byte codes having 1-byte headers expressed by FFh (h indicates a hexadecimal notation). For example, the codes FFD0h to FFD7h are allocated to the RSTm, a code FFD8h is allocated to the SOI, and a code FFD9h is allocated to the EOI.
In the JPEG, these markers are required to be inserted at suitable locations relative to a border of byte units in the compressed and encoded bit stream. However, since the compression and encoding of the JPEG is variable length encoding, if the markers are inserted into the compressed and encoded bit stream as they are, the insertion locations of the markers relative to the byte borders will not become constant.
Therefore, when inserting markers into a compressed and encoded bit stream, it is necessary to generate bit data having a suitable data length for adjusting the insertion locations (referred to as fill bits) and insert these before the markers.
Summarizing the disadvantages discussed above, when generating a stream of the image data compressed and encoded by for example the JPEG, it is necessary to insert various markers into the bit stream generated by the compression and encoding, generate fill bits, and insert them before the markers at every insertion of the markers. Such processing requires complex control, so such processing has been conventionally carried out by software. However, the software includes many processing routines requiring many execution cycles, for example, processing of bit shifting and connecting the data. Further, the image data becomes huge in many cases. Therefore it suffers from the disadvantage that a practical processing speed is difficult to obtain with software.
Also, even when such processing is realized by hardware, it suffers from the disadvantages in that the configuration is complex and the size of the circuit becomes great. This becomes a problem particularly when such a circuit is to be formed in an LSI. Improvement has therefore been desired.